package com.yauta.freegift.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@org.springframework.stereotype.Controller
public class IndexController implements Controller {

	public static String arrayToString(String[] array) {
		if (array == null)
			return "null";
		StringBuilder sb = new StringBuilder();
		for (String str : array)
			sb.append(str);
		return sb.toString();
	}

	@RequestMapping(value = "/")
	public ModelAndView index(HttpServletRequest request, HttpServletResponse response) throws Exception {
		return handleRequest(request, response);
	}

	@Override
	@RequestMapping(value = "/index")
	public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
		// TODO Auto-generated method stub
		log.debug("index requested:" + arrayToString(request.getParameterValues("a")));
		return new ModelAndView("index");
	}

}
